package com.oly.cms.general.controller.api;

import java.util.List;

import com.oly.cms.general.model.po.WebArticleCountSort;
import com.oly.cms.general.service.cache.WebArticleSortCacheService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/api/articleCount")
public class ArticleCountSortApiController {

    @Autowired
    private WebArticleSortCacheService articleCountService;

    @GetMapping("/look/{pageSize}/{themeName}")
    public List<WebArticleCountSort> listWebArticleCountOrderByLook(@PathVariable("themeName") String themeName,
            @PathVariable("pageSize") int pageSize) {
        return articleCountService.listWebArticleCountOrderByLook(pageSize, themeName);
    }

    @GetMapping("/like/{pageSize}/{themeName}")
    public List<WebArticleCountSort> listWebArticleCountOrderByLike(@PathVariable("themeName") String themeName,
            @PathVariable("pageSize") int pageSize) {

        return articleCountService.listWebArticleCountOrderByLike(pageSize, themeName);
    }

    @GetMapping("/score/{pageSize}/{themeName}")
    public List<WebArticleCountSort> listWebArticleCountOrderByScore(@PathVariable("themeName") String themeName,
            @PathVariable("pageSize") int pageSize) {
        return articleCountService.listWebArticleCountOrderByScore(pageSize, themeName);
    }

    @GetMapping("/collect/{pageSize}/{themeName}")
    public List<WebArticleCountSort> listWebArticleCountOrderByCollect(@PathVariable("themeName") String themeName,
            @PathVariable("pageSize") int pageSize) {

        return articleCountService.listWebArticleCountOrderByCollect(pageSize, themeName);
    }

    @GetMapping("/share/{pageSize}/{themeName}")
    public List<WebArticleCountSort> listWebArticleCountOrderByShare(@PathVariable("themeName") String themeName,
            @PathVariable("pageSize") int pageSize) {

        return articleCountService.listWebArticleCountOrderByShare(pageSize, themeName);
    }

}
